home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / cpp_libs / awe2-0_1.lha / awe2-0.1 / Src / RCS / LowerBoundedFifo.cc,v < prev    next >
Text File  |  1989-05-09  |  2KB  |  151 lines

  1. head     3.2;
  2. branch   ;
  3. access   ;
  4. symbols  ;
  5. locks    grunwald:3.2; strict;
  6. comment  @@;
  7.  
  8.  
  9. 3.2
  10. date     89.02.20.15.35.54;  author grunwald;  state Exp;
  11. branches ;
  12. next     3.1;
  13.  
  14. 3.1
  15. date     88.12.20.13.48.58;  author grunwald;  state Exp;
  16. branches ;
  17. next     1.2;
  18.  
  19. 1.2
  20. date     88.10.30.13.04.31;  author grunwald;  state Exp;
  21. branches ;
  22. next     1.1;
  23.  
  24. 1.1
  25. date     88.09.18.16.42.26;  author grunwald;  state Exp;
  26. branches ;
  27. next     ;
  28.  
  29.  
  30. desc
  31. @@
  32.  
  33.  
  34. 3.2
  35. log
  36. @Start using Gnu library heaps for schedulers
  37. @
  38. text
  39. @// This may look like C code, but it is really -*- C++ -*-
  40. // 
  41. // Copyright (C) 1988 University of Illinois, Urbana, Illinois
  42. //
  43. // written by Dirk Grunwald (grunwald@@cs.uiuc.edu)
  44. //
  45. #include "LowerBoundedFifo.h"
  46. #include "CpuMultiplexor.h"
  47. #include "stream.h"
  48. #include "assert.h"
  49.  
  50. LowerBoundedFifo::LowerBoundedFifo(int defaultLength)
  51.     : (defaultLength), lowerBoundLock(0)
  52. {
  53.     //
  54.     // do nothing
  55.     //
  56. }
  57.  
  58. void LowerBoundedFifo::add(AwesimeFifoItem *t) {
  59.     LockedFifo::add(t);
  60.     lowerBoundLock.release();
  61. }
  62.  
  63. bool
  64. LowerBoundedFifo::remove(AwesimeFifoItem *item) {
  65.  
  66.     (void) lowerBoundLock.reserve();
  67.     bool ok = LockedFifo::remove(item);
  68.     //
  69.     //    The remove had better have worked, or there's something screwy
  70.     //  with the semaphores.
  71.     //
  72.     assert(ok);
  73.     return(ok);
  74. }
  75.  
  76. bool
  77. LowerBoundedFifo::removeIfFound(AwesimeFifoItem *item) {
  78.     bool ok = LockedFifo::removeIfFound(item);
  79.     if (ok) {
  80.     (void) lowerBoundLock.reserve();
  81.     }
  82.     return(ok);
  83. }
  84.  
  85. bool
  86. LowerBoundedFifo::doDelete(AwesimeFifoIndex& index) {
  87.     //
  88.     // This is problematic. Since this is a LockedFifo, this person
  89.     // will be the only one with access to the list. If he blocks
  90.     // at this point, he's dead-meat.
  91.     //
  92.     // So, is this an error? If so, should we protect him?
  93.     //
  94.     bool whaHap = AwesimeFifo::doDelete(index);
  95.     if (whaHap) {
  96.     bool noBlock = lowerBoundLock.reserveNoBlock();
  97.     assert( noBlock );
  98.     }
  99.     return(whaHap);
  100. }
  101.  
  102. unsigned int
  103. LowerBoundedFifo::size()
  104. {
  105.     return(AwesimeFifo::size());
  106. }
  107.  
  108. void LowerBoundedFifo::classPrintOn(ostream& s)
  109. {
  110.     s << "[LowerBoundedFifo " ;
  111.     s << "\tSemaphore\n";
  112.     s << lowerBoundLock;
  113.     s << "\n";
  114.     s << "\tFifo";
  115.     AwesimeFifo::classPrintOn(s);
  116.     s << "\n]\n" ;
  117. }
  118. @
  119.  
  120.  
  121. 3.1
  122. log
  123. @Steay version
  124. @
  125. text
  126. @@
  127.  
  128.  
  129. 1.2
  130. log
  131. @*** empty log message ***
  132. @
  133. text
  134. @@
  135.  
  136.  
  137. 1.1
  138. log
  139. @Initial revision
  140. @
  141. text
  142. @d1 6
  143. d8 1
  144. d27 1
  145. d30 5
  146. a34 3
  147.     if (!ok) {
  148.     lowerBoundLock.release();
  149.     }
  150. @
  151.